gtkwindow: Add private API to mark as subsurface
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 21 Aug 2014 15:34:09 +0000 (17:34 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 26 Aug 2014 21:06:01 +0000 (23:06 +0200)
This is a rather hackish way to let GTK+ widgets declare popup windows
as subsurfaces, so they may work on wayland without the need of xdg_popup,
and without many changes yet on the GTK+ side.

https://bugzilla.gnome.org/show_bug.cgi?id=695504

gtk/gtkwindow.c
gtk/gtkwindowprivate.h

index f0b8aea6a8e91580f62e8a9b61ff929b329f6713..514c6db3ed3cfa6ce48cc45aea7ed27f11015e6f 100644 (file)
@@ -229,6 +229,8 @@ struct _GtkWindowPrivate
 
   guint    drag_possible             : 1;
 
+  guint    use_subsurface            : 1;
+
   GtkGesture *multipress_gesture;
 };
 
@@ -6337,6 +6339,12 @@ gtk_window_realize (GtkWidget *widget)
       break;
     }
 
+#ifdef GDK_WINDOWING_WAYLAND
+  if (priv->use_subsurface &&
+      GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)))
+    attributes.window_type = GDK_WINDOW_SUBSURFACE;
+#endif
+
   attributes.title = priv->title;
   attributes.wmclass_name = priv->wmclass_name;
   attributes.wmclass_class = priv->wmclass_class;
@@ -11697,3 +11705,15 @@ gtk_window_enable_debugging (GtkWindow *window,
   else
     gtk_window_set_debugging (TRUE, TRUE, warn);
 }
+
+void
+gtk_window_set_use_subsurface (GtkWindow *window,
+                               gboolean   use_subsurface)
+{
+  GtkWindowPrivate *priv = window->priv;
+
+  g_return_if_fail (GTK_IS_WINDOW (window));
+  g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (window)));
+
+  priv->use_subsurface = use_subsurface;
+}
index 3d7b08685df75c9ce108a0f03e031f71e01f7ef6..ce19d1be2f119496f3cb76ecc6603e37bc7d8772 100644 (file)
@@ -119,6 +119,9 @@ void    _gtk_window_get_popover_position (GtkWindow                   *window,
 GdkPixbuf *gtk_window_get_icon_for_size (GtkWindow *window,
                                          gint       size);
 
+void       gtk_window_set_use_subsurface (GtkWindow *window,
+                                          gboolean   use_subsurface);
+
 G_END_DECLS
 
 #endif /* __GTK_WINDOW_PRIVATE_H__ */